import os
import sys
import xmmsclient
import xmmsqt4
from constants import *
from PyQt4 import QtCore, QtGui
from playController import PlayController
from playlist import Playlist
from yaxmms2_ui import Ui_MainWindow


class Yaxmms2(Ui_MainWindow, QtGui.QMainWindow):
    def __init__(self, xmms2):
        QtGui.QMainWindow.__init__(self)
        self.setupUi(self)
        self.xmms2 = xmms2
        self.playlist = Playlist(self.xmms2)
        self.playController = PlayController(self.xmms2)
        self.playerLayout.addWidget(self.playController)
        self.playlistDock_2.setWidget(self.playlist)
        


if __name__ == "__main__":
    xmms2 = xmmsclient.XMMS("yaxmms2")
    try:
        xmms2.connect(os.getenv("XMMSPATH"))
    except IOError, detail:
        print "Could not connect to xmms2!", detail
        exit(1)

    app = QtGui.QApplication(sys.argv)
    xmmsqt4.XMMSConnector(xmms2, app)    
    client = Yaxmms2(xmms2)
    client.show()
    sys.exit(app.exec_())
    
